package com.example.emailWeb.ntru.encrypt;

/**
 * A simple program demonstrating the use of NtruEncrypt and NtruSign.
 */
public class NtruDemo {

    public static void main(String[] args) {
        encrypt();
        System.out.println();
    }

    private static void encrypt() {
        System.out.println("NTRU encryption");

        // create an instance of NtruEncrypt with a standard parameter set
        NtruEncrypt ntru = new NtruEncrypt(EncryptionParameters.APR2011_439);

        // create an encryption key pair
        EncryptionKeyPair kp = ntru.generateKeyPair();

        String msg = "The quick brown fox;汉语测试;特殊符号:Ёё Жж";
        System.out.println("  Before encryption: " + msg);

        // encrypt the message with the public key created above
        byte[] enc = ntru.encrypt(msg.getBytes(), kp.getPublic());

        byte[] dec = ntru.decrypt(enc,kp.pub.h,kp.priv.t,kp.priv.fp);

        // decrypt the message with the private key created above
//        byte[] dec = ntru.decrypt(enc, kp);

        // print the decrypted message
        System.out.println("  After decryption:  " + new String(dec));
    }

}